package com.example.b_308.myapplication.view.user.register;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.b_308.myapplication.R;
import com.example.b_308.myapplication.model.Staff;
import com.example.b_308.myapplication.view.base.BaseFragment;

/**
 * Created by B-308 on 2017/11/23.
 */
public class ConsummatePersonFragment extends BaseFragment implements View.OnClickListener {

    EditText et_pi, et_pii, et_piii;
    Button btn_complete_person;

    @Override
    protected void init() {
        btn_complete_person = findViewById(R.id.btn_complete_person);
        et_pi = findViewById(R.id.et_pi);
        et_pii = findViewById(R.id.et_pii);
        et_piii = findViewById(R.id.et_piii);
        btn_complete_person.setOnClickListener(this);
    }

    @Override
    protected View setContentView(LayoutInflater inflater) {
        return inflater.inflate(R.layout.fragment_consummate_person, null, false);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_complete_person:
                Staff staff = new Staff();
                staff.setName(et_pi.getText().toString());
                staff.setDepartment_name(et_pii.getText().toString());
                staff.setTitle(et_piii.getText().toString());
                if (et_pi.length() != 0 && et_pii.length() != 0 && et_piii.length() != 0) {
                    btn_complete_person.setSelected(true);
                    ((RegisterActivity) getActivity()).next(this, staff);
                }else {
                    fail("请完善个人信息！");
                }
                break;
        }
    }


}
